package com.kongjs.application.controller;

import com.kongjs.application.service.DockerOperationService;
import com.kongjs.application.service.GitOperationService;
import com.kongjs.application.service.MavenOperationService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/deploy")
public class DeployController {
    @Resource
    private GitOperationService gitOperationService;
    @Resource
    private MavenOperationService mavenOperationService;
    @Resource
    private DockerOperationService dockerOperationService;

    @RequestMapping("/git/{id}")
    public String git(@PathVariable String id){
        gitOperationService.clone(id);
        return "OK";
    }

    @RequestMapping("/mvn/{id}")
    public String mvn(@PathVariable String id){
        mavenOperationService.pack(id);
        return "OK";
    }

    @RequestMapping("/docker/{id}")
    public String docker(@PathVariable String id){
        dockerOperationService.restartContainer(id);
        return "OK";
    }
}
